﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;
using PlanningGIS.Win.Controls;

namespace PlanningGIS.TocContextMenu.Form
{
    /// <summary>
    /// 作用：图层属性
    /// 作者：
    /// 修改日期：2009-06-19
    /// </summary>
    public partial class frmMapAttribute : DevComponents.DotNetBar.Office2007Form
    {
        /// <summary>
        /// 
        /// </summary>
        private IMapControl3 m_MapControl;
        /// <summary>
        /// 
        /// </summary>
        public IMapControl3 MapControl
        {
            set { m_MapControl = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public frmMapAttribute()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmMapAttribute_Load(object sender, EventArgs e)
        {
            try
            {
                int value = int.Parse(m_MapControl.BackColor.ToString());
                int Blue = value / (256 * 256);
                int Green = (value - Blue * (256 * 256)) / 256;
                int Red = value - Blue * (256 * 256) - Green * 256;
                this.drpdwColor.SelectedColor = Color.FromArgb(Red, Green, Blue);
                FrmMapScale frmMapScale = new FrmMapScale();
                frmMapScale.MapControl = m_MapControl;
                frmMapScale.InitializeTreeView();
                frmMapScale.Dock = DockStyle.Fill;
                this.tabControlPanel2.Controls.Add(frmMapScale);
                
            }
            catch (Exception ex)
            {
                MsgHelper.ShowErrorMsgbox(ex.Message);
            }
        }
        
        /// <summary>
        /// 应用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnApply_Click(object sender, EventArgs e)
        {

            if (drpdwColor.SelectedColor.Name == "ffedeada")//2009-06-29 by ym
                MsgHelper.ShowInfomationMsgbox("地图不支持透明色!");
            else
            {
                int value = drpdwColor.SelectedColor.R + (drpdwColor.SelectedColor.G * 256) + (drpdwColor.SelectedColor.B * 256 * 256);
               m_MapControl.BackColor = int.Parse(value.ToString());
               this.Close();
            }
        }

    }
}
